<template>
  <div>
    <el-form ref="myform">
      <el-form-item>
        <el-checkbox-group v-model="checkList" @change="handleCheckedChange">
          <el-checkbox label="1">盘盈资产自动新增入库</el-checkbox>
          <el-checkbox label="2">已盘资产修改内容自动更新资产信息</el-checkbox>
          <el-checkbox label="3">未盘、盘亏资产自动清理报废</el-checkbox>
        </el-checkbox-group>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import { synchronousData } from '@neu/dcam-ui/api/inventoryPlan'

export default {
  name: 'InventoryResultDealForm',
  props: {
    // 根据ids可判断是新建还是更新
    ids: {
      required: false,
      type: Number,
      default: -1
    }
  },
  data() {
    return {
      checkList: [],
      checkedArray: []
    }
  },
  watch: {
    // 监控ids的变化，初始化表单数据
    ids: {
      handler(newVal, oldVal) {
        this.fetch()
      },
      immediate: true
    }
  },
  created() {

  },
  methods: {
    // 初始化表单数据
    fetch() {

    },
    /** 结果状态确认 */
    onOk() {
      if (this.checkedArray.length === 0) {
        this.$message({
          type: 'warning',
          message: '请选择一项处理规则!'
        })
        return
      }
      return new Promise(resolve => {
        resolve(synchronousData(this.ids, this.checkedArray.toString()))
      })
    },
    // 重置表单
    reset() {
      this.$refs.myform.resetFields()
    },
    handleCheckedChange(value) {
      this.checkedArray = value
    }
  }
}
</script>
